import  { AppPostT } from '@utils/request'
import { BasicPageSearch } from "@/models/basicType";
import { SoftwarePageResult, Software } from '@/models/software'

// 获取全部软件列表
export async function getSoftwares(data:BasicPageSearch) {
    const res = await AppPostT<SoftwarePageResult>("/soft/list",data)
    console.log("getSoftwares request:", data, ", result:", res)
    return res.data ? res.data : {} as SoftwarePageResult
}

// 获取热门软件列表
export async function getRecSoftwares(maxNum: number = 4) {
    const data = {};
    const res = await AppPostT<Software[]>("/soft/hot",data)
    console.log("getRecSoftwares request:", data, ", result:", res)
    let result = res.data ? res.data : [] as Software[]
    if(result.length > maxNum) {
        result = result.slice(0, maxNum)
    }
    return result;
}
